package o;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.forum.base.card.bean.PostTime;
import com.huawei.appgallery.forum.message.bean.ForumRemindCardBean;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import o.bvj.c;
import o.bvj.d;
import o.bvj.j;

public class bvp extends androidx.recyclerview.widget.RecyclerView.a {
    private List<ForumRemindCardBean> ˊ;
    private String ˋ;
    private a ˎ;
    private final Context ˏ;
    private e ॱ = new e();

    public interface a {
        void ˎ(long j, String str);
    }

    static class b implements o.bwp.b {
        private int ˊ;
        private WeakReference<bvp> ˏ;

        public b(bvp o_bvp, int i) {
            this.ˏ = new WeakReference(o_bvp);
            this.ˊ = i;
        }

        public void ˏ(int i) {
            bvp o_bvp = (bvp) this.ˏ.get();
            if (o_bvp == null) {
                bqx.ˋ("ForumListAdapter", "get adapter null");
                return;
            }
            ForumRemindCardBean forumRemindCardBean = (ForumRemindCardBean) o_bvp.ˊ.get(this.ˊ);
            if (!dof.ʽ(forumRemindCardBean.ʽ()) && forumRemindCardBean.ॱˊ() == 0) {
                forumRemindCardBean.ˎ(i);
            }
            o_bvp.ˊ();
        }
    }

    static class e extends Handler {
        private e() {
        }

        void ˋ() {
            postDelayed(new Runnable(this) {
                final /* synthetic */ e ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    bwr.ˊ.ˎ();
                }
            }, 1500);
        }
    }

    public bvp(Context context, String str) {
        this.ˏ = context;
        this.ˋ = str;
        this.ˊ = new ArrayList();
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        return new bwu(LayoutInflater.from(viewGroup.getContext()).inflate(o.bvj.e.ᐝ, viewGroup, false));
    }

    public void ॱ(@NonNull s sVar, int i) {
        if ((sVar instanceof bwu) && this.ˊ != null && this.ˊ.size() > 0) {
            ˎ((bwu) sVar, i, this.ˊ);
        }
    }

    private void ˎ(bwu o_bwu, final int i, List<ForumRemindCardBean> list) {
        if (list != null && list.size() > 0) {
            final ForumRemindCardBean forumRemindCardBean = (ForumRemindCardBean) list.get(i);
            ˋ(o_bwu, forumRemindCardBean);
            o_bwu.ʼॱ.setVisibility(0);
            if (i == ˏ() - 1) {
                o_bwu.ʼॱ.setVisibility(8);
            }
            o_bwu.ॱˋ.setOnClickListener(new evx(this) {
                final /* synthetic */ bvp ˋ;

                public void ˋ(View view) {
                    if (!dof.ʽ(forumRemindCardBean.ॱॱ())) {
                        bwy.ˏ().ˏ(this.ˋ.ˏ, this.ˋ.ˋ, forumRemindCardBean.ॱˊ(), forumRemindCardBean.ॱॱ());
                        this.ˋ.ˊ(false, i);
                    } else if (!dof.ʽ(forumRemindCardBean.ʽ()) && forumRemindCardBean.ॱˊ() == 0) {
                        if (this.ˋ.ˏ instanceof Activity) {
                            ((eke) cdb.ॱ(eke.class)).ˏ((Activity) this.ˋ.ˏ);
                            this.ˋ.ˊ(true, i);
                        } else {
                            bqx.ॱ("ForumListAdapter", " context is not instance of Activity");
                        }
                    }
                    if (forumRemindCardBean.ॱˊ() == 7) {
                        brd.ॱ.ॱ(bqy.ˋ().ˎ(this.ˋ.ˏ));
                    }
                }
            });
        }
    }

    private void ˊ(boolean z, int i) {
        if (this.ˊ != null && this.ˊ.size() > 0) {
            ForumRemindCardBean forumRemindCardBean = (ForumRemindCardBean) this.ˊ.get(i);
            long ᐝ = (long) forumRemindCardBean.ᐝ();
            forumRemindCardBean.ˎ(0);
            ˊ(i);
            if (z) {
                this.ॱ.ˋ();
            } else {
                bwr.ˊ.ॱ(ᐝ);
            }
            if (this.ˎ != null) {
                this.ˎ.ˎ(ᐝ, this.ˋ);
            }
        }
    }

    private void ˏ(bwu o_bwu, int i) {
        LayoutParams layoutParams = o_bwu.ॱˋ.getLayoutParams();
        layoutParams.height = i;
        o_bwu.ॱˋ.setLayoutParams(layoutParams);
    }

    private void ˋ(bwu o_bwu, ForumRemindCardBean forumRemindCardBean) {
        ॱ(o_bwu, (long) forumRemindCardBean.ᐝ(), forumRemindCardBean.ˊ());
        ˎ(o_bwu, forumRemindCardBean.ॱˊ());
        ˋ(o_bwu, forumRemindCardBean.ʼ());
        ˋ(o_bwu, forumRemindCardBean.ˏॱ());
    }

    private void ॱ(bwu o_bwu, long j, boolean z) {
        if (z) {
            o_bwu.ʾ.setVisibility(8);
            if (j >= 100) {
                o_bwu.ᐝॱ.setVisibility(0);
                o_bwu.ᐝॱ.setText("99+");
            } else if (j > 0) {
                o_bwu.ᐝॱ.setVisibility(0);
                o_bwu.ᐝॱ.setText(String.valueOf(j));
            } else {
                o_bwu.ᐝॱ.setVisibility(8);
            }
            int dimensionPixelOffset = ContentManager.getInstant().getContext().getResources().getDimensionPixelOffset(d.ˋॱ);
            o_bwu.ᐝॱ.setMinHeight(dimensionPixelOffset);
            if (j >= 10) {
                dimensionPixelOffset = o_bwu.ᐝॱ.getContext().getResources().getDimensionPixelSize(d.ˏॱ);
                o_bwu.ᐝॱ.setPadding(dimensionPixelOffset, 0, dimensionPixelOffset, 0);
                o_bwu.ᐝॱ.setBackgroundResource(c.ॱᐝ);
                return;
            }
            o_bwu.ᐝॱ.setPadding(0, 0, 0, 0);
            o_bwu.ᐝॱ.setBackgroundResource(c.ʻॱ);
            o_bwu.ᐝॱ.setMinWidth(dimensionPixelOffset);
            return;
        }
        o_bwu.ᐝॱ.setVisibility(8);
        if (j > 0) {
            o_bwu.ʾ.setVisibility(0);
        } else {
            o_bwu.ʾ.setVisibility(8);
        }
    }

    private void ˎ(bwu o_bwu, int i) {
        switch (i) {
            case 0:
                o_bwu.ॱᐝ.setText(j.ˏˎ);
                o_bwu.ʻॱ.setImageResource(c.ˏॱ);
                return;
            case 1:
                o_bwu.ॱᐝ.setText(j.ˌ);
                o_bwu.ʻॱ.setImageResource(c.ͺ);
                return;
            case 2:
                o_bwu.ॱᐝ.setText(j.ˉ);
                o_bwu.ʻॱ.setImageResource(c.ˊॱ);
                return;
            case 3:
                o_bwu.ॱᐝ.setText(j.ᐝॱ);
                o_bwu.ʻॱ.setImageResource(c.ʼ);
                return;
            case 4:
                o_bwu.ॱᐝ.setText(j.ʼॱ);
                o_bwu.ʻॱ.setImageResource(c.ॱˊ);
                return;
            case 5:
                o_bwu.ॱᐝ.setText(j.ॱˋ);
                o_bwu.ʻॱ.setImageResource(c.ʽ);
                return;
            case 6:
                o_bwu.ॱᐝ.setText(j.ʾ);
                o_bwu.ʻॱ.setImageResource(c.ᐝ);
                return;
            case 7:
                o_bwu.ॱᐝ.setText(j.ॱᐝ);
                o_bwu.ʻॱ.setImageResource(c.ˎ);
                return;
            default:
                return;
        }
    }

    private void ˋ(bwu o_bwu, String str) {
        if (dof.ʽ(str)) {
            o_bwu.ʽॱ.setVisibility(8);
            ˏ(o_bwu, (int) this.ˏ.getResources().getDimension(d.ˋ));
            return;
        }
        ˏ(o_bwu, (int) this.ˏ.getResources().getDimension(d.ˊ));
        o_bwu.ʽॱ.setVisibility(0);
        o_bwu.ʽॱ.setText(str);
    }

    private void ˋ(bwu o_bwu, PostTime postTime) {
        if (postTime == null || dof.ʽ(postTime.ˊ())) {
            o_bwu.ʿ.setVisibility(8);
            return;
        }
        o_bwu.ʿ.setVisibility(0);
        o_bwu.ʿ.setText(btc.ˏ(this.ˏ, postTime));
    }

    private void ʼ(int i) {
        bwp.c.ˎ(new b(this, i)).ˊ();
    }

    public void ˋ(List<ForumRemindCardBean> list) {
        this.ˊ = list;
        if (this.ˊ != null && this.ˊ.size() > 0) {
            int i = 0;
            while (i < this.ˊ.size()) {
                ForumRemindCardBean forumRemindCardBean = (ForumRemindCardBean) this.ˊ.get(i);
                if (dof.ʽ(forumRemindCardBean.ʽ()) || forumRemindCardBean.ॱˊ() != 0) {
                    ˊ();
                    i++;
                } else {
                    ʼ(i);
                    return;
                }
            }
        }
    }

    public int ˏ() {
        return this.ˊ == null ? 0 : this.ˊ.size();
    }

    public void ॱ(a aVar) {
        this.ˎ = aVar;
    }
}
